package leetcode.biweekly.week86;

//Solution2Test
public class Solution2 {

	public boolean isStrictlyPalindromic(int n) {
		int l = 2, r = n - 2;
		for (int i = l; i <= r; i++) {
			int cur = n;
			int p = 0 , mul = 1;
			while (cur > 0) {
				int num = cur % i;
				p += num * mul;
				cur /= i;
				mul *=10;
			}
			if (!check(p)) {
				return false;
			}
		}
		return true;
	}

	private boolean check(int p) {
		String str = String.valueOf(p);
		int l = 0, r = str.length() - 1;
		while (l < r) {
			if (str.charAt(l) != str.charAt(r)) {
				return false;
			}
			l++;
			r--;
		}
		return true;
	}

}
